{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Solution(object):\n",
    "    def findContentChildren(self, g, s):\n",
    "        \"\"\"\n",
    "        :type g: List[int]\n",
    "        :type s: List[int]\n",
    "        :rtype: int\n",
    "        \"\"\"\n",
    "        g.sort(reverse=True)\n",
    "        s.sort(reverse=True)\n",
    "        cnt = 0\n",
    "        p_g = 0\n",
    "        p_s = 0\n",
    "        while p_g < len(g) and p_s < len(s):\n",
    "            if g[p_g] > s[p_s]:\n",
    "                p_g = p_g + 1\n",
    "                continue\n",
    "            else:\n",
    "                p_g = p_g + 1\n",
    "                p_s = p_s + 1\n",
    "                cnt = cnt + 1\n",
    "\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = Solution()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.findContentChildren([1,2,3], [1,2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
